﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Light.Utility;
using Light.Framework.Contract;
using System.Web;

namespace Light.Framework.Castle
{
    /// <summary>
    /// 系统用户作用范围，用于执行一些非用户的系统操作
    /// </summary>
    public class SuperScope : IDisposable
    {
        const string session_name = "session_superscope_user";

        public SuperScope()
        {
            WebHelper.SetSession(session_name, ServerApplication.User);
            ServerApplication.User = new Light.Framework.Model.User { IsSuper = true, IsApprole = true };
        }

        public void Dispose()
        {
            ServerApplication.User = WebHelper.GetSession<IUser>(session_name);
        }
    }
}
